import instance from '../utils/request'

// 职位推荐分页查询
export const getJobPostings = (pageNum, pageSize) => {
    return instance({
        url: `jobPostings/recommendPage?pageNum=${pageNum}&pageSize=${pageSize}`,
        method: 'GET',
    })
}
export const updateOnlineResume = (id, newData) => {
    return instance({
        url: `/resume/update/${id}`,
        method: "PUT",
        data: newData,
    });
}

//职位发布删除
export const deletejobPostings = (id) => {
    return instance({
        url: `/jobPostings/delete/${id}`,
        method: 'DELETE',
    });
};


// 职位分页查询
export const getJobPosting = (pageNum, pageSize, positionName, city) => {
    return instance({
        url: '/jobPostings/selectPage',
        method: 'POST',
        data: {
            pageNum: pageNum,
            pageSize: pageSize,
            positionName: positionName,
            city: city
        }
    })
}
// 企业分页查询职位
export const getEmploymentJobPosting = (pageNum, pageSize) => {
    return instance({
        url: '/jobPostings/selectPage',
        method: 'POST',
        data: {
            pageNum: pageNum,
            pageSize: pageSize,
        }
    })
}


//新增职位
export const addjobPostings = (newData) => {
    return instance({
        url: `/jobPostings/add`,
        method: "POST",
        data: newData
    });
}

//查询职位详细信息
export const getjobPostingDetailed = (id) => {
    return instance({
        url: `/jobPostings/select/${id}`,
        method: 'GET',
    })
}

//职位收藏
export const addjobCollect = (id) => {
    return instance({
        url: '/jobCollect/add',
        method: 'POST',
        data: {
            positionId: id
        }
    })
}

// 职位收藏分页查询
export const getJobCollect = (pageNum, pageSize) => {
    return instance({
        url: `/jobCollect/selectPage?pageNum=${pageNum}&pageSize=${pageSize}`,
        method: 'GET',
    })
}


//职位收藏删除
export const deleteJobCollect = (id) => {
    return instance({
        url: `/jobCollect/delete/${id}`,
        method: 'DELETE',
    });
};

//投递简历
export const submitResume = (positionId, userId, resumeId, status) => {
    return instance({
        url: `/resumeSubmit/add`,
        method: 'POST',
        data: {
            positionId: positionId,
            userId: userId,
            resumeId: resumeId,
            status: status
        }
    });
};

//企业修改面试状态
export const updateState = (id, status) => {
    return instance({
        url: `/resumeSubmit/update/${id}`,
        method: 'PUT',
        data: {
            status: status
        }
    });
};

// 职位浏览历史记录
export const getHistoryJob = (pageNum, pageSize) => {
    return instance({
        url: `/job/history/selectPage?pageNum=${pageNum}&pageSize=${pageSize}`,
        method: 'GET',
    });
};

// 单个删除位浏览历史记录
export const deleteJobHistory = (id) => {
    return instance({
        url: `/job/history/delete/${id}`,
        method: 'DELETE',
    });
};


//职位标签
export const getJobTags = () => {
    return instance({
        url: `/jobPostings/getJobTags`,
        method: 'GET',
    });
};

//根据公司名称分页查询职位
export const getJobByCompanyName = (pageNum, pageSize, companyName) => {
    return instance({
        url: `/jobPostings/job-postings/selectPage?pageNum=${pageNum}&pageSize=${pageSize}&companyName=${companyName}`,
        method: 'GET',
    });
};

//根据公司名称分页查询职位
export const getJobByStudent = (pageNum, pageSize) => {
    return instance({
        url: `/resumeSubmit/selectJobByStudent?pageNum=${pageNum}&pageSize=${pageSize}`,
        method: 'GET',
    });
};


//职位排行榜
export const getJobPostingsRank = () => {
    return instance({
        url: `/jobPostings/rank`,
        method: 'GET',
    })
}